/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tpgen.patterns;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import tpgen.grammar.Node;
import tpgen.grammar.Symbol;
import tpgen.grammar.Variable;

/**
 *
 * @author shanki
 */
public class Axiom {
    private Node node;
    
    public Axiom(Node node) {
        this.node = node;
    }

    Collection<? extends Variable> getVariables() {
        final Set<Variable> variables = new HashSet<Variable>();

        node.traverse(new Node.NodeVisitor() {

            @Override
            public void visit(Symbol symbol) {
                if (symbol instanceof Variable) {
                    variables.add((Variable)symbol);
                }
            }
        });        
        
        return variables;
    }

    @Override
    public String toString() {
        return node.toUserString();
    }
    
    public Axiom reconstruct(Node.NodeConstructor nodeConstructor) {
        return new Axiom(node.reconstruct(nodeConstructor));
    }

}
